package com.holly.common_view.message;

import android.os.Bundle;

/**
 * 仿照官方 message
 *
 * @author Joey Huang（QQ:273179370）
 * @created 2016/6/29
 */
public class Msg implements Type{
    public int what;
    public String who;
    public String to;
    public int arg1;
    public int arg2;
    public int arg3;
    public int arg4;
    public int arg5;
    public Object obj;
    public Bundle bundle;

    public Msg(String who) {
        this.who = who;
    }

    public Msg what(int what) {
        this.what = what;
        return this;
    }

    public Msg who(String who) {
        this.who = who;
        return this;
    }

    public Msg to(String to) {
        this.to = to;
        return this;
    }

    public Msg arg1(int arg1) {
        this.arg1 = arg1;
        return this;
    }

    public Msg arg2(int arg2) {
        this.arg2 = arg2;
        return this;
    }

    public Msg arg3(int arg3) {
        this.arg3 = arg3;
        return this;
    }

    public Msg arg4(int arg4) {
        this.arg4 = arg4;
        return this;
    }

    public Msg arg5(int arg5) {
        this.arg5 = arg5;
        return this;
    }

    public Msg obj(Object obj) {
        this.obj = obj;
        return this;
    }

    public Msg bundle(Bundle bundle) {
        this.bundle = bundle;
        return this;
    }

    @Override
    public String toString() {
        return "Msg{" +
                "what=" + what +
                ", who=" + who +
                ", to=" + to +
                ", arg1=" + arg1 +
                (obj==null?"":(" obj="+obj.toString()))+
                (bundle==null?"":(" bundle="+bundle.toString()))+
                '}';
    }

    public void release() {
        this.bundle = null;
        this.obj = null;
    }
}
